#include <stdio.h>
#include <iostream>

class CVirtual
{
	public:
		CVirtual() {
			member1 = 1;
			member2 = 2;
			printf("CVirtual()\r\n");
		}

		virtual ~CVirtual() {
			printf("~CVirtual()\r\n");
		}

		virtual void fun1()
		{
			printf("fun1()\r\n");
		}

		virtual void fun2() {
			printf("fun2()\r\n");
		}

	private:
		int member1;
		int member2;
};

int main(int argc, char * argv[])
{
	CVirtual object;

	object.fun1();
	object.fun2();

	return 0;
}

/*
	CVirtual()
	fun1()
	fun2()
	~CVirtual()
*/

#if 0
int main(int argc, char * argv[])
{
 8048710:	55                   	push   %ebp
 8048711:	89 e5                	mov    %esp,%ebp
 8048713:	53                   	push   %ebx
 8048714:	83 e4 f0             	and    $0xfffffff0,%esp
 8048717:	83 ec 20             	sub    $0x20,%esp
	CVirtual object;
 804871a:	8d 44 24 14          	lea    0x14(%esp),%eax	// eax=(esp+0x14)
 804871e:	89 04 24             	mov    %eax,(%esp)	// (esp)=eax
 8048721:	e8 a6 00 00 00       	call   80487cc <_ZN8CVirtualC1Ev>

	object.fun1();
 8048726:	8d 44 24 14          	lea    0x14(%esp),%eax	//eax=(esp+0x14)
 804872a:	89 04 24             	mov    %eax,(%esp)	// (esp)=eax
 804872d:	e8 1c 01 00 00       	call   804884e <_ZN8CVirtual4fun1Ev>
	object.fun2();
 8048732:	8d 44 24 14          	lea    0x14(%esp),%eax	// eax=(esp+0x14)
 8048736:	89 04 24             	mov    %eax,(%esp)	// (esp)=eax
 8048739:	e8 24 01 00 00       	call   8048862 <_ZN8CVirtual4fun2Ev>

	return 0;
 804873e:	bb 00 00 00 00       	mov    $0x0,%ebx	// ebx=0
 8048743:	8d 44 24 14          	lea    0x14(%esp),%eax	// eax=(esp+0x14)
 8048747:	89 04 24             	mov    %eax,(%esp)	// (esp)=eax
 804874a:	e8 af 00 00 00       	call   80487fe <_ZN8CVirtualD1Ev>
 804874f:	89 d8                	mov    %ebx,%eax	// eax=ebx
 8048751:	eb 18                	jmp    804876b <main+0x5b>
 8048753:	89 c3                	mov    %eax,%ebx	// ebx=eax
 8048755:	8d 44 24 14          	lea    0x14(%esp),%eax	// eax=(esp+0x14)
 8048759:	89 04 24             	mov    %eax,(%esp)	// (esp)=eax
 804875c:	e8 9d 00 00 00       	call   80487fe <_ZN8CVirtualD1Ev>
 8048761:	89 d8                	mov    %ebx,%eax
 8048763:	89 04 24             	mov    %eax,(%esp)
 8048766:	e8 85 fe ff ff       	call   80485f0 <_Unwind_Resume@plt>
}
 804876b:	8b 5d fc             	mov    -0x4(%ebp),%ebx
 804876e:	c9                   	leave  
 804876f:	c3                   	ret

#endif

#if 0

/*
 * intel
 */
00000000000011e9 <main>:
    11e9:	f3 0f 1e fa          	endbr64 
    11ed:	55                   	push   %rbp
    11ee:	48 89 e5             	mov    %rsp,%rbp
    11f1:	53                   	push   %rbx
    11f2:	48 83 ec 38          	sub    $0x38,%rsp
    11f6:	89 7d cc             	mov    %edi,-0x34(%rbp)
    11f9:	48 89 75 c0          	mov    %rsi,-0x40(%rbp)
    11fd:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    1204:	00 00 
    1206:	48 89 45 e8          	mov    %rax,-0x18(%rbp)
    120a:	31 c0                	xor    %eax,%eax
    120c:	48 8d 45 d0          	lea    -0x30(%rbp),%rax		// rax=(rbp-0x30)
    1210:	48 89 c7             	mov    %rax,%rdi		// rdi=rax
    1213:	e8 cc 00 00 00       	callq  12e4 <_ZN8CVirtualC1Ev>
    1218:	48 8d 45 d0          	lea    -0x30(%rbp),%rax		// rax=(rbp-0x30)
    121c:	48 89 c7             	mov    %rax,%rdi		// rdi=rax
    121f:	e8 62 01 00 00       	callq  1386 <_ZN8CVirtual4fun1Ev>
    1224:	48 8d 45 d0          	lea    -0x30(%rbp),%rax		// rax=(rbp-0x30)
    1228:	48 89 c7             	mov    %rax,%rdi		// rdi=rax
    122b:	e8 76 01 00 00       	callq  13a6 <_ZN8CVirtual4fun2Ev>
    1230:	bb 00 00 00 00       	mov    $0x0,%ebx		// ebx=0
    1235:	48 8d 45 d0          	lea    -0x30(%rbp),%rax		// rax=(rbp-0x30)
    1239:	48 89 c7             	mov    %rax,%rdi		// rdi=rax
    123c:	e8 e7 00 00 00       	callq  1328 <_ZN8CVirtualD1Ev>
    1241:	89 d8                	mov    %ebx,%eax		// eax=ebx
    1243:	48 8b 55 e8          	mov    -0x18(%rbp),%rdx		// rdx=(rbp-0x18)
    1247:	64 48 33 14 25 28 00 	xor    %fs:0x28,%rdx
    124e:	00 00 
    1250:	74 25                	je     1277 <main+0x8e>
    1252:	eb 1e                	jmp    1272 <main+0x89>
    1254:	f3 0f 1e fa          	endbr64 
    1258:	48 89 c3             	mov    %rax,%rbx		// rbx=rax
    125b:	48 8d 45 d0          	lea    -0x30(%rbp),%rax		// rax=(rbp-0x30)
    125f:	48 89 c7             	mov    %rax,%rdi		// rdi=rax
    1262:	e8 c1 00 00 00       	callq  1328 <_ZN8CVirtualD1Ev>
    1267:	48 89 d8             	mov    %rbx,%rax		// rax=rbx
    126a:	48 89 c7             	mov    %rax,%rdi		// rdi=rax
    126d:	e8 7e fe ff ff       	callq  10f0 <_Unwind_Resume@plt>
    1272:	e8 49 fe ff ff       	callq  10c0 <__stack_chk_fail@plt>
    1277:	48 83 c4 38          	add    $0x38,%rsp
    127b:	5b                   	pop    %rbx
    127c:	5d                   	pop    %rbp
    127d:	c3                   	retq   

00000000000012e4 <_ZN8CVirtualC1Ev>:
    12e4:	f3 0f 1e fa          	endbr64 
    12e8:	55                   	push   %rbp
    12e9:	48 89 e5             	mov    %rsp,%rbp
    12ec:	48 83 ec 10          	sub    $0x10,%rsp
    12f0:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    12f4:	48 8d 15 4d 2a 00 00 	lea    0x2a4d(%rip),%rdx        # 3d48 <_ZTV8CVirtual+0x10>
    12fb:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    12ff:	48 89 10             	mov    %rdx,(%rax)	// (rax)=rdx
    1302:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1306:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%rax)	// (rax+0x8)=1
    130d:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1311:	c7 40 0c 02 00 00 00 	movl   $0x2,0xc(%rax)	// (rax+0xc)=0x2
    1318:	48 8d 3d e6 0c 00 00 	lea    0xce6(%rip),%rdi        # 2005 <_ZStL19piecewise_construct+0x1>
    131f:	e8 bc fd ff ff       	callq  10e0 <puts@plt>
    1324:	90                   	nop
    1325:	c9                   	leaveq 
    1326:	c3                   	retq   
    1327:	90                   	nop

0000000000001328 <_ZN8CVirtualD1Ev>:
    1328:	f3 0f 1e fa          	endbr64 
    132c:	55                   	push   %rbp
    132d:	48 89 e5             	mov    %rsp,%rbp
    1330:	48 83 ec 10          	sub    $0x10,%rsp
    1334:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    1338:	48 8d 15 09 2a 00 00 	lea    0x2a09(%rip),%rdx        # 3d48 <_ZTV8CVirtual+0x10>
    133f:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1343:	48 89 10             	mov    %rdx,(%rax)	// (rax)=rdx
    1346:	48 8d 3d c4 0c 00 00 	lea    0xcc4(%rip),%rdi        # 2011 <_ZStL19piecewise_construct+0xd>
    134d:	e8 8e fd ff ff       	callq  10e0 <puts@plt>	// puts()
    1352:	90                   	nop
    1353:	c9                   	leaveq 
    1354:	c3                   	retq   
    1355:	90                   	nop

0000000000001356 <_ZN8CVirtualD0Ev>:
    1356:	f3 0f 1e fa          	endbr64 
    135a:	55                   	push   %rbp
    135b:	48 89 e5             	mov    %rsp,%rbp
    135e:	48 83 ec 10          	sub    $0x10,%rsp
    1362:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    1366:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    136a:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    136d:	e8 b6 ff ff ff       	callq  1328 <_ZN8CVirtualD1Ev>
    1372:	48 8b 45 f8          	mov    -0x8(%rbp),%rax	// rax=(rbp-0x8)
    1376:	be 10 00 00 00       	mov    $0x10,%esi	// esi=0x10
    137b:	48 89 c7             	mov    %rax,%rdi	// rdi=rax
    137e:	e8 2d fd ff ff       	callq  10b0 <_ZdlPvm@plt>
    1383:	c9                   	leaveq 
    1384:	c3                   	retq   
    1385:	90                   	nop

0000000000001386 <_ZN8CVirtual4fun1Ev>:
    1386:	f3 0f 1e fa          	endbr64 
    138a:	55                   	push   %rbp
    138b:	48 89 e5             	mov    %rsp,%rbp
    138e:	48 83 ec 10          	sub    $0x10,%rsp
    1392:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    1396:	48 8d 3d 81 0c 00 00 	lea    0xc81(%rip),%rdi        # 201e <_ZStL19piecewise_construct+0x1a>
    139d:	e8 3e fd ff ff       	callq  10e0 <puts@plt>
    13a2:	90                   	nop
    13a3:	c9                   	leaveq 
    13a4:	c3                   	retq   
    13a5:	90                   	nop

00000000000013a6 <_ZN8CVirtual4fun2Ev>:
    13a6:	f3 0f 1e fa          	endbr64 
    13aa:	55                   	push   %rbp
    13ab:	48 89 e5             	mov    %rsp,%rbp
    13ae:	48 83 ec 10          	sub    $0x10,%rsp
    13b2:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)	// (rbp-0x8)=rdi
    13b6:	48 8d 3d 69 0c 00 00 	lea    0xc69(%rip),%rdi        # 2026 <_ZStL19piecewise_construct+0x22>
    13bd:	e8 1e fd ff ff       	callq  10e0 <puts@plt>
    13c2:	90                   	nop
    13c3:	c9                   	leaveq 
    13c4:	c3                   	retq   
    13c5:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    13cc:	00 00 00 
    13cf:	90                   	nop

/*
 * arm
 */
000000000040092c <main>:
  40092c:	a9bc7bfd 	stp	x29, x30, [sp, #-64]!
  400930:	910003fd 	mov	x29, sp
  400934:	f9000bf3 	str	x19, [sp, #16]	// [sp+16]=x19
  400938:	b9002fa0 	str	w0, [x29, #44]	// [x29+44]=w0
  40093c:	f90013a1 	str	x1, [x29, #32]	// [x29+32]=x1
  400940:	9100c3a0 	add	x0, x29, #0x30	// x0=x29+0x30
  400944:	94000031 	bl	400a08 <_ZN8CVirtualC1Ev>
  400948:	9100c3a0 	add	x0, x29, #0x30	// x0=x29+0x30
  40094c:	94000059 	bl	400ab0 <_ZN8CVirtual4fun1Ev>
  400950:	9100c3a0 	add	x0, x29, #0x30	// x0=x29+0x30
  400954:	94000060 	bl	400ad4 <_ZN8CVirtual4fun2Ev>
  400958:	52800013 	mov	w19, #0x0                   	// #0
  40095c:	9100c3a0 	add	x0, x29, #0x30	// x0=x29+0x30
  400960:	9400003d 	bl	400a54 <_ZN8CVirtualD1Ev>
  400964:	2a1303e0 	mov	w0, w19		// w0=w19
  400968:	14000006 	b	400980 <main+0x54>
  40096c:	aa0003f3 	mov	x19, x0
  400970:	9100c3a0 	add	x0, x29, #0x30	// x0=x29+0x30
  400974:	94000038 	bl	400a54 <_ZN8CVirtualD1Ev>
  400978:	aa1303e0 	mov	x0, x19
  40097c:	97ffffa9 	bl	400820 <_Unwind_Resume@plt>
  400980:	f9400bf3 	ldr	x19, [sp, #16]
  400984:	a8c47bfd 	ldp	x29, x30, [sp], #64
  400988:	d65f03c0 	ret

0000000000400a08 <_ZN8CVirtualC1Ev>:
  400a08:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400a0c:	910003fd 	mov	x29, sp
  400a10:	f9000fa0 	str	x0, [x29, #24]
  400a14:	90000000 	adrp	x0, 400000 <_init-0x750>
  400a18:	912fc001 	add	x1, x0, #0xbf0	// x1=400bf0
  400a1c:	f9400fa0 	ldr	x0, [x29, #24]	// x0=[x29+24]
  400a20:	f9000001 	str	x1, [x0]	// [x0]=x1
  400a24:	f9400fa0 	ldr	x0, [x29, #24]	// x0=[x29+24]
  400a28:	52800021 	mov	w1, #0x1                   	// #1
  400a2c:	b9000801 	str	w1, [x0, #8]	// [x0+8]=w1
  400a30:	f9400fa0 	ldr	x0, [x29, #24]	// x0=[x29+24]
  400a34:	52800041 	mov	w1, #0x2                   	// #2
  400a38:	b9000c01 	str	w1, [x0, #12]	// [x0+12]=w1
  400a3c:	90000000 	adrp	x0, 400000 <_init-0x750>
  400a40:	912ec000 	add	x0, x0, #0xbb0	// x0=400bb0
  400a44:	97ffff6f 	bl	400800 <puts@plt>
  400a48:	d503201f 	nop
  400a4c:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400a50:	d65f03c0 	ret

0000000000400a54 <_ZN8CVirtualD1Ev>:
  400a54:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400a58:	910003fd 	mov	x29, sp
  400a5c:	f9000fa0 	str	x0, [x29, #24]	// [x29+24]=x0
  400a60:	90000000 	adrp	x0, 400000 <_init-0x750>
  400a64:	912fc001 	add	x1, x0, #0xbf0
  400a68:	f9400fa0 	ldr	x0, [x29, #24]	// x0=[x29+24]
  400a6c:	f9000001 	str	x1, [x0]	// [x0]=x1
  400a70:	90000000 	adrp	x0, 400000 <_init-0x750>
  400a74:	912f0000 	add	x0, x0, #0xbc0
  400a78:	97ffff62 	bl	400800 <puts@plt>
  400a7c:	d503201f 	nop
  400a80:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400a84:	d65f03c0 	ret

0000000000400a88 <_ZN8CVirtualD0Ev>:
  400a88:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400a8c:	910003fd 	mov	x29, sp
  400a90:	f9000fa0 	str	x0, [x29, #24]	// [x29+24]=x0
  400a94:	f9400fa0 	ldr	x0, [x29, #24]	// x0=[x29+24]
  400a98:	97ffffef 	bl	400a54 <_ZN8CVirtualD1Ev>
  400a9c:	d2800201 	mov	x1, #0x10                  	// #16
  400aa0:	f9400fa0 	ldr	x0, [x29, #24]	// x0=[x29+24]
  400aa4:	97ffff43 	bl	4007b0 <_ZdlPvm@plt>
  400aa8:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400aac:	d65f03c0 	ret

0000000000400ab0 <_ZN8CVirtual4fun1Ev>:
  400ab0:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400ab4:	910003fd 	mov	x29, sp
  400ab8:	f9000fa0 	str	x0, [x29, #24]	// [x29+24]=x0
  400abc:	90000000 	adrp	x0, 400000 <_init-0x750>
  400ac0:	912f4000 	add	x0, x0, #0xbd0
  400ac4:	97ffff4f 	bl	400800 <puts@plt>
  400ac8:	d503201f 	nop
  400acc:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400ad0:	d65f03c0 	ret

0000000000400ad4 <_ZN8CVirtual4fun2Ev>:
  400ad4:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400ad8:	910003fd 	mov	x29, sp
  400adc:	f9000fa0 	str	x0, [x29, #24]	// [x29=24]=x0
  400ae0:	90000000 	adrp	x0, 400000 <_init-0x750>
  400ae4:	912f6000 	add	x0, x0, #0xbd8
  400ae8:	97ffff46 	bl	400800 <puts@plt>
  400aec:	d503201f 	nop
  400af0:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400af4:	d65f03c0 	ret

#endif
